# Contributor: Francesco Colista <fcolista@alpinelinux.org>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=notus-scanner
pkgver=22.6.2
pkgrel=0
pkgdesc="Notus is a vulnerability scanner for creating results from local security checks "
url="https://github.com/greenbone/notus-scanner"
arch="noarch"
license="AGPL-3.0-or-later"
pkgusers="gvm"
pkggroups="gvm"
depends="
	mosquitto
	paho-mqtt-c
	py3-gnupg
	py3-packaging
	py3-paho-mqtt
	py3-psutil
	"
makedepends="py3-gpep517 python3-dev py3-poetry-core"
checkdepends="py3-pytest"
subpackages="$pkgname-openrc $pkgname-pyc"
source="$pkgname-$pkgver.tar.gz::https://github.com/greenbone/notus-scanner/archive/refs/tags/v$pkgver.tar.gz
	notus-scanner.initd
	"

build() {
	gpep517 build-wheel \
		--wheel-dir .dist \
		--output-fd 3 3>&1 >&2
}

check() {
	python3 -m venv --clear --without-pip --system-site-packages .testenv
	.testenv/bin/python3 -m installer .dist/*.whl
	.testenv/bin/python3 -m pytest
}

package() {
	python3 -m installer -d "$pkgdir" .dist/*.whl
	install -d -o $pkgusers -g $pkggroups "$pkgdir"/var/lib/notus
	install -d -o $pkgusers -g $pkggroups "$pkgdir"/var/lib/openvas/plugins/notus/products
	install -d -o $pkgusers -g $pkggroups "$pkgdir"/run/notus-scanner
	install -Dm755 "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
}

sha512sums="
ecbbb79950908641c2b83d379d141b189b8e0e27cac17753cbb381a5f4ebf28d7100f60bd24fc284c2681abc889f6fee36a64f469ac0b37323940eaeae7e7522  notus-scanner-22.6.2.tar.gz
d5d6adb9ecdb074cefcc1575e277918bbbde83ddf75997c23bd53609147b434ef7f41ae08090625593616d0829059c141c4ec7f2e567167a40a2e2b3fcf3e903  notus-scanner.initd
"
